//
//  HQCollectViewCell.m
//  MobileiOS
//
//  Created by 郝庆松 on 2018/7/14.
//  Copyright © 2018年 PCITC. All rights reserved.
//

#import "HQCollectViewCell.h"

@implementation HQCollectViewCell

/**
 生成Cell
 
 @param tableView 列表
 @return ***
 */
+(instancetype)cellWithTableView:(UITableView*)tableView{
    static NSString *CellIdentifer = @"HQCollectViewCell";
    HQCollectViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifer];
    if(!cell){
        [tableView registerNib:[UINib nibWithNibName:CellIdentifer bundle:nil] forCellReuseIdentifier:CellIdentifer];
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifer];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

/**
 数据源
 
 @param dataInfo 数据源
 */
-(void)setDataInfo:(id)dataInfo{
    _dataInfo = dataInfo;
    _lookBigItem.dataInfo = _dataInfo;
    
    [_s_img setImageWithURL:[NSURL URLWithString:_dataInfo[@"s_img"]]];
    _s_name.text = [NSString stringWithFormat:@"  %@  ",_dataInfo[@"s_name"]];
    [self sourceLabel:_fengge withTitle:@"产品风格: " withData:_dataInfo[@"fengge"]];
    [self sourceLabel:_caizhi withTitle:@"产品材质: " withData:_dataInfo[@"caizhi"]];
    [self sourceLabel:_username withTitle:@"生产厂家: " withData:_dataInfo[@"username"]];
    [self sourceLabel:_peixu withTitle:@"产品卖点: " withData:_dataInfo[@"peixu"]];
}

-(void)sourceLabel:(UILabel *)sourceLabel withTitle:(NSString *)title withData:(NSString *)data{
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",title,data]];
    [attributeStr addAttribute:NSForegroundColorAttributeName value:[self colorHexValue:0x647180] range:NSMakeRange(0,[title length])];
    [attributeStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0,[title length])];
    [attributeStr addAttribute:NSForegroundColorAttributeName value:[self colorHexValue:0x233040] range:NSMakeRange([title length],[data length])];
    [attributeStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange([title length],[data length])];
    sourceLabel.attributedText = attributeStr;
}

@end
